package com.unohacha.qqj.fzdr.personal.model;

import com.unohacha.qqj.fzdr.common.bean.HttpResult;
import com.unohacha.qqj.fzdr.personal.bean.UserInfoBean;
import com.unohacha.qqj.fzdr.common.http.RetrofitManager;
import com.unohacha.qqj.fzdr.personal.presenter.IPersonalPresenter;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

// 我的 业务逻辑实现
public class PersonalImpl {

    private IPersonalPresenter iPersonalPresenter;

    public PersonalImpl(IPersonalPresenter iPersonalPresenter) {
        this.iPersonalPresenter = iPersonalPresenter;
    }


    public void getUserInfo(String token) {
        // 请求个人信息
        Call<HttpResult<UserInfoBean>> call = RetrofitManager.getInstance().getUserInfo(token);
        call.enqueue(new Callback<HttpResult<UserInfoBean>>() {
            @Override
            public void onResponse(Call<HttpResult<UserInfoBean>> call, Response<HttpResult<UserInfoBean>> response) {
                UserInfoBean result = response.body().getData();
                if (result != null) {
                    iPersonalPresenter.showUserInfo(result);
                }
            }

            @Override
            public void onFailure(Call<HttpResult<UserInfoBean>> call, Throwable t) {

            }
        });
    }
}
